package testView;

import static org.junit.Assert.*;

import org.junit.Test;

import model.*;
/**
@author Team EBE
Tests the DiagramImpl.java and ClassEditor.java Models
*/


public class UMLTest{
	
	
	ClassImpl Tester1 = new ClassImpl("C1");
	ClassImpl Tester2 = new ClassImpl("C2");
	
	ClassImpl Test = new ClassImpl();
	ClassImpl Test2 = new ClassImpl();
		
	/**
	 * 
	 * 
	 * 
	 */

	// this method tests creating a new diagram and setting a size
	@Test
	public void testDiagram(){
		
		DiagramImpl d = new DiagramImpl();
		int sizex;
		int sizey;
		
		sizex = d.getSizeX();
		sizey = d.getSizeY();
		
		assertEquals(sizex, 1024);
		assertEquals(sizey, 768);
		
	}
	
	// this method tests adding operations and attributes to a class, and then adding the class to the diagram
	@Test
	public void testDiagramBuild(){
		
		DiagramImpl d1 = new DiagramImpl();
		String A1 = "AttributeImpl 1";
		String O1 = "OperationImpl 1";
		String C1 = "Class 1";
		

		
		d1.addClass(C1);
		d1.getClassImpl(0).addAttribute(A1, "string", '+');
		d1.getClassImpl(0).addOperation(O1, "char", '-');
		
		
		assertNotNull(d1);
		
		
	}
	
	// this method tests adding a relationship between two classes to the diagram
	@Test
	public void DiagramRelationTest(){
		
		DiagramImpl d3 = new DiagramImpl();
		
		d3.addRelationship(Tester1, Tester2);
		
		assertNotNull(Tester1);
		assertNotNull(Tester2);
		
		assertNotSame(Tester1, Tester2);
		
		
	}
	
	// this method tests to see if attributes and operations exist, and then checking to see if the editor exists
	@Test
	public void ClassEditorTest(){
		
		int sizeX = 2;
		int sizeY = 3;
		
		Test.getAttributes();
		
		assertNotNull(Test);
		
		Test2.getOperations();
		
		assertNotNull(Test2);
			
		Test.setWidth(sizeX);
		Test2.setHeight(sizeY);
		
		assertNotSame(Test, Test2);
		
		assertEquals(2, Test.getWidth());
		assertEquals(3, Test2.getHeight());
		
		Test.setoX(0);
		Test.setoY(0);
		
		assertEquals(0, Test.getoX());
		assertEquals(0, Test.getoY());
		
		Test2.setName("Test");
		assertEquals("Test", Test2.getName());
		
	}
	
	
	
}